<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Gets the normalized value of the provided color channel</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="imagickpixel.getcolorquantum.html">« ImagickPixel::getColorQuantum</a></li>
      <li style="float: right;"><a href="imagickpixel.getcolorvaluequantum.html">ImagickPixel::getColorValueQuantum »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.imagickpixel.html">ImagickPixel</a></li>
    <li>Gets the normalized value of the provided color channel</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="imagickpixel.getcolorvalue" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ImagickPixel::getColorValue</h1>
  <p class="verinfo">(PECL imagick 2, PECL imagick 3)</p><p class="refpurpose"><span class="refname">ImagickPixel::getColorValue</span> &mdash; <span class="dc-title">Gets the normalized value of the provided color channel</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-imagickpixel.getcolorvalue-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ImagickPixel::getColorValue</strong></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$color</code></span>): <span class="type">float</span></div>

  <p class="para rdfs-comment">
   Retrieves the value of the color channel specified, as a floating-point
   number between 0 and 1.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-imagickpixel.getcolorvalue-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">color</code></dt>

     <dd>

      <p class="para">
       The color to get the value of, specified as one of the Imagick color
       constants. This can be one of the RGB colors, CMYK colors, alpha and
       opacity e.g (Imagick::COLOR_BLUE, Imagick::COLOR_MAGENTA).
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-imagickpixel.getcolorvalue-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   The value of the channel, as a normalized floating-point number, throwing
   ImagickPixelException on error.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-imagickpixel.getcolorvalue-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2970">
    <p><strong>示例 #1 Basic <span class="function"><strong>Imagick::getColorValue()</strong></span> usage</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />$color&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">ImagickPixel</span><span style="color: #007700">(</span><span style="color: #DD0000">'rgba(90%,&nbsp;20%,&nbsp;20%,&nbsp;0.75)'</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #DD0000">"Alpha&nbsp;value&nbsp;is&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">$color</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getColorValue</span><span style="color: #007700">(</span><span style="color: #0000BB">Imagick</span><span style="color: #007700">::</span><span style="color: #0000BB">COLOR_ALPHA</span><span style="color: #007700">).</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">.</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"Red&nbsp;value&nbsp;is&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">$color</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getColorValue</span><span style="color: #007700">(</span><span style="color: #0000BB">Imagick</span><span style="color: #007700">::</span><span style="color: #0000BB">COLOR_RED</span><span style="color: #007700">).</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"Green&nbsp;value&nbsp;is&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">$color</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getColorValue</span><span style="color: #007700">(</span><span style="color: #0000BB">Imagick</span><span style="color: #007700">::</span><span style="color: #0000BB">COLOR_GREEN</span><span style="color: #007700">).</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"Blue&nbsp;value&nbsp;is&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">$color</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getColorValue</span><span style="color: #007700">(</span><span style="color: #0000BB">Imagick</span><span style="color: #007700">::</span><span style="color: #0000BB">COLOR_BLUE</span><span style="color: #007700">).</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">.</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"Cyan&nbsp;value&nbsp;is&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">$color</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getColorValue</span><span style="color: #007700">(</span><span style="color: #0000BB">Imagick</span><span style="color: #007700">::</span><span style="color: #0000BB">COLOR_CYAN</span><span style="color: #007700">).</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"Magenta&nbsp;value&nbsp;is&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">$color</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getColorValue</span><span style="color: #007700">(</span><span style="color: #0000BB">Imagick</span><span style="color: #007700">::</span><span style="color: #0000BB">COLOR_MAGENTA</span><span style="color: #007700">).</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"Yellow&nbsp;value&nbsp;is&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">$color</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getColorValue</span><span style="color: #007700">(</span><span style="color: #0000BB">Imagick</span><span style="color: #007700">::</span><span style="color: #0000BB">COLOR_YELLOW</span><span style="color: #007700">).</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #DD0000">"Black&nbsp;value&nbsp;is&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">$color</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getColorValue</span><span style="color: #007700">(</span><span style="color: #0000BB">Imagick</span><span style="color: #007700">::</span><span style="color: #0000BB">COLOR_BLACK</span><span style="color: #007700">).</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Alpha value is 0.74999618524453

Red value is 0.90000762951095
Green value is 0.2
Blue value is 0.2

Cyan value is 0.90000762951095
Magenta value is 0.2
Yellow value is 0.2
Black value is 0
</pre></div>
    </div>
   </div>
  </p>
 </div>


</div></div></div></body></html>